package threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: admin
 * @Description:
 * @Date: 2018/8/5 16:40
 */

public class NewFixed {
    public static void main(String[] args) {
        ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(3);
        for (int i = 0; i < 10; i++) {
            final int index=i;
            newFixedThreadPool.execute(() -> {
                try {
                    System.out.println(Thread.currentThread().getId()+"\t"+ index);
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            });
        }
    }
}
